package com.sdp.irrigation.bean;

import org.springframework.context.ApplicationContext;


public class BeanFactory {

	private static ApplicationContext context;
	
	public static void setContext(ApplicationContext context)
	{
		BeanFactory.context = context;
	}

	public static <T> T getBean(Class<T> clazz) {
		T t = context.getBean(clazz);
		if (t != null) {
			return t;
		} else {
			return null;
		}
		
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBean(String className) {
		T t = (T) context.getBean(className);
		if (t != null) {
			return t;
		} else {
			return null;
		}
	}

}
